/*
	Simple Software Renderer (SSRenderer)
	Copyright (C) 2007 Piotr Orzechowski <piotr.orzechowski@gmail.com>

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
*/

#include "./SSRSurface.h"

namespace ssr
{

SSRSurface* SSRSurface::CreateSurface(u32 width, u32 height)
{
	SSRSurface* surface = new SSRSurface();

	surface->m_Width  = width;
	surface->m_Height = height;
	surface->m_Pitch  = width;

	surface->m_pBuffer = new color32[width * height];

	return surface;
}

SSRSurface* SSRSurface::CreateSurface(const SSRSurface &source)
{
	SSRSurface* surface = new SSRSurface();

	surface->m_Width  = source.m_Width;
	surface->m_Height = source.m_Height;
	surface->m_Pitch  = source.m_Pitch;

	u32 buffSize = source.m_Width * source.m_Height;

	surface->m_pBuffer = new color32[buffSize];
	::memcpy(surface->m_pBuffer, source.m_pBuffer, sizeof(color32) * buffSize);

	return surface;
}

} // namespace

